import React from 'react';
import {NumberInput} from 'jh-lib';
import {Button, Form, InputNumber, Tooltip} from "antd";

export default class NumericInputDemo extends React.Component {
    formRef = React.createRef();

    constructor(props) {
        super(props);
        this.state = {value: ''};
    }

    onChange = value => {
        this.setState({value});
    };

    render() {
        return (
            <>
                <p>value:{this.state.value}</p>
                <p><Button onClick={() => {
                    if(this.formRef.current) {
                        console.log(this.formRef.current.getFieldsValue());
                    }
                }}>getAjaxData</Button></p>
                <Form ref={this.formRef}>
                    <NumberInput style={{width: 200}}
                                 compLabel={`默认`}
                                 fieldName={'number'}
                                 placeholder={'输入数字'}
                        // value={0}
                                 onChange={this.onChange}
                                 max={100}
                                 min={-100}
                                 floatNum={2}
                                 format={''}
                    />
                    <NumberInput style={{width: 200}}
                                 compLabel={`百分比`}
                                 fieldName={'number1'}
                                 placeholder={'输入数字'}
                        // value={0}
                                 onChange={this.onChange}
                                 floatNum={1}
                                 format={'%'}
                    />
                    <NumberInput style={{width: 200}}
                                 compLabel={`货币`}
                                 fieldName={'number2'}
                                 placeholder={'输入数字'}
                        // value={0}
                                 onChange={this.onChange}
                                 floatNum={4}
                                 format={'$'}
                                 max={''}
                                 min={''}
                    />
                </Form>
            </>
        );
    }
}